<template>
	<!-- 添加弹框 -->
		 <el-dialog  width="100%" title=""    visible :show-close="true" :append-to-body="true" @close="cancel"  :close-on-click-modal="false"> 
			<div class="">
				<!-- <button type="button" @click="cancel" name="button">返回</button> -->
				<div class="tou">
					<h1>老师课表预览</h1>
					<el-button type="primary" class="but" size="small"  @click="cancel">返回</el-button>
				</div>
					<el-select v-model="vlsid" class="select-block1" @change="ass()">
								<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
					</el-select>
				<div id="calendar2"></div>
			</div>
	 </el-dialog> 
</template>
<script type="text/javascript">
import { mapState } from 'vuex'
import moment from 'moment';
import qs from 'qs'
// import './zh-cn'
export default {
props: ['params'],
	components : {
	},
		data () {
				return {
					vbjmc:'',
					vbt:'',
					vsj:'',
					vjsmc:'',
					vlsid:'',
					comboxlist:[],
					outerVisible:false,
				}
		},
		created () {
				// this.$store.dispatch('changeTitle','班级课表');//修改title
				// this.$store.dispatch('changeRouterIndex','/educa/banji');//修改路由
				this.vlsid = this.params
				this.arr()
				this.getcomboxlist(); //laoshi
		},

		methods: {
			ass(){
				$('#calendar2').fullCalendar('removeEventSources') ;
        	 var ss = this.$store.state.api + 'pk/lskblist1?lsid='+this.vlsid;
			 $('#calendar2').fullCalendar('addEventSource',ss) ;
			},
			arr(){
				var ae = this
				// alert(ae.vjsid)
				var time = this.$.getLocalTime(new Date().getTime())
				$(function(){
					$('#calendar2').fullCalendar({
							arr :ae.$route.query.iid,
							height:900,
							header: {
								// left: 'prevYear,prev,today,next,nextYear',
								left: 'prev,next today',
								center: 'title',
								right: 'month,agendaWeek,agendaDay'
								// right: 'month,agendaWeek,agendaDay,listWeek'
							},
							defaultDate: time,
							navLinks: true, // can click day/week names to navigate views
							editable: true,
							eventLimit: true, // allow "more" link when too many events

							events:  {
									url: ae.$store.state.api + 'pk/lskblist1',
									type: 'get',
									data: {
											 	lsid:ae.vlsid,
									 },
									error: function() {
											this.$message.warning('数据获取失败!');
									},
							},
							//获取点击的时间
							dayClick : function(date, allDay, jsEvent, view) {
									var selDate = date.format();// 获取当前点击日期
									// $("#datetimepicker").val(selDate);
									// $("#taskModal").modal();
									// alert(selDate)
							},
							eventClick : function(event, jsEvent, view) {

								ae.outerVisible = true
								ae.vbt = event.title
								ae.vbjmc = event.bjmc
								ae.vjsmc = event.jsmc
								ae.vsj = event.sj
								// console.log(event)
								// console.log(jsEvent)
								// console.log(view)
								// alert(this.outerVisible)
								// alert(export)
								// this.outerVisible = true
									// var selDate = date.format();// 获取当前点击日期
									// $("#datetimepicker").val(selDate);
									// $("#taskModal").modal();
									// alert(event.title)
									// console.log(event.title)
									// console.log(jsEvent)
									// console.log(event,jsEvent,view)
							},
						});
					})

			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      yhid: logininfo.id,
						xxid: logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/getlslist',  params2 )
                 .then(res => {
                console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
//					console.log(this.comboxlist)
                 }).catch(res => {
                  this.searchLoading = false;
				})
			},
			getjslist(){
				var logininfo = JSON.parse(localStorage.logininfo) ;
					// this.searchLoading = true;
					this.axios.get(this.$store.state.api + 'xxjs/mc',{
						params:{
								xxid:logininfo.xxid,
						}
					}).then( res => {
							let data = res.data.data;
							this.jsboxlist = data;
					}).catch( res => {
					})
			},
			cancel() {
				this.$emit('close', {
					type: 'lskb',
					cancel: true
				})
			},
		},
		mounted () {

		},

		computed: {
				...mapState([
						'api'//域名
				]),
				multipleDeleteDisabled () {
//						console.log(this.multipleDelNum)
						if (this.multipleDelNum) {
								return false;
						}else{
								return true
						}
				}
		}
}
</script>
<style lang="less" scoped >
#calendar2{
	width: 96%;
	height: 80%;
	margin-top: 50px;
	margin-left:2%;
}
.tou{
	width: 100%;
	height: 20px;
	line-height: 50px;
	.but{
		position: absolute;
		top:4%;
		left: 2%;
	}
	h1{
		text-align: center;
		font-size: 20px;
	}
}
a{
	color: #000;
}
.select-block1{
	width: 10%;
	position: absolute;
	top:85px;
	left: 23%;
}

.select-block3{
	width: 10%;
	position: absolute;
	top:85px;
	left: 35%;
}
.class1  {
background-color:green;
border-color:green;
color:yellow;
}

.class2{
background-color:purple;
border-color:purple;
color:white;
}
.fc-grid .fc-day-number{padding: 0 2px; position:relative}
.fc-grid .fc-day-number span.solarday{float:right;color:#999}
.fc-grid .fc-day-number span.holiday{position:absolute; left:40%}

</style>
